/*whois.rexx 1.0*/
signal on break_c
say "Content-type: text/html";say
say "
Whois"
l="rexxsupport.library";if ~show("L",l) then;if ~addlib(l,0,-30) then call err "can't find" l
l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then call err "can't find" l
l="rxsocket.library";if ~show("L",l) then;if ~addlib(l,0,-30) then call err "can't find" l
parse arg a +11 who
select
when a~="searchText=" then call err "bad request"
when who=="" then call err "You must give me something to search for!"
otherwise nop
end
s=socket("INET","STREAM")
if s<0 then call err "no socket"
remote.addraddr=resolve("rs.internic.net")
if remote.addraddr=="-1" then call err "can't resolve rs.internic.net
(Are you online?)"
remote.addrport=43
if connect(s,"REMOTE")<0 then call err "can't connect"
req="WHOIS" who||d2c(10)||d2c(13)
if send(s,req)~=length(req) then call err "send error"
say "Whois results for '"who"'
"
r=1
do while r>0
r=recv(s,"BUF",256)>0
if r>0 then call writech("STDOUT",buf)
end
if r<0 then call err "recv error"
else say "
"
exit
break_c:
say
call err "break"
exit
err:
parse arg msg
say "
Sorry, internal script error:
"msg"